import { useEffect, useState } from "react";
import Node from "./Node";
import { Box } from "@mui/material";

function FolderTree(props) {
    const [currentSelected, setCurrentSelect] = useState(null) 
    function hanldeOnSelected(e, id) {
        setCurrentSelect(id)
    }
    useEffect(()=> {
        console.log(`id change to ${currentSelected}`)
        if (props.onSelectedChange) {
            props.onSelectedChange(currentSelected)
        }
    }, [props.onSelectedChange, currentSelected])
    return (
        <Box sx={{minWidth:'280px', minHeight:'360px'}}><Node id={0} isOpen={true} onSelected={hanldeOnSelected} currentSelected={currentSelected}  hasChild = {true} name={'我的文件'}/></Box>
    )
}

export default FolderTree